﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KqAutoDesign.Base
{
    public class Tools
    {
        public static void CopyDirectory(string sourceDir, string destinationDir)
        {
            // 确保目标目录存在
            if(!Directory.Exists(destinationDir)) 
                Directory.CreateDirectory(destinationDir);

            // 获取源目录的文件列表
            foreach (string file in Directory.GetFiles(sourceDir))
            {
                string fileName = Path.GetFileName(file);
                string destFile = Path.Combine(destinationDir, fileName);
                File.Copy(file, destFile, true); // true 表示如果目标文件已存在，则覆盖它
            }

            // 递归复制子目录
            foreach (string dir in Directory.GetDirectories(sourceDir))
            {
                string destDir = Path.Combine(destinationDir, Path.GetFileName(dir));
                CopyDirectory(dir, destDir);
            }
        }
    }
}
